//
//  HSYSpeechManager.m
//  HSY
//
//  Created by 陈浩 on 2017/4/21.
//  Copyright © 2017年 金开门. All rights reserved.
//

#import "HSYSpeechManager.h"
#import <AVFoundation/AVFoundation.h>

@implementation HSYSpeechManager

+(instancetype) instance{
    static HSYSpeechManager *manager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[self alloc] init];
    });
    return manager;
}

- (void)speechMessage:(NSString *)message{
    AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:message];
//    utterance.rate *= 0.8;
    AVSpeechSynthesizer *synth = [[AVSpeechSynthesizer alloc] init];
    //获取当前系统语音
    AVSpeechSynthesisVoice *voice = [AVSpeechSynthesisVoice voiceWithLanguage:[AVSpeechSynthesisVoice currentLanguageCode]];
    utterance.voice = voice;
    [synth speakUtterance:utterance];

}


@end
